package controllers

import (
	"github.com/revel/revel"
	"waterblabla/app/models"
)

type Feedback struct {
	Controller
}

func (c Feedback) Add() revel.Result {
	type Req struct {
		models.QS `,inline valid:"Required"`
		Words     string `json:"words" valid:"Required"`
	}
	var req Req
	// parse
	if err := models.ParseBodyAndValidate(c.body, &req); err != nil {
		return c.RenderResult(err)
	}

	return c.RenderResult(models.AddFeedback(req.Qid, req.Words))
}
